package leetcode;

import java.util.Arrays;

public class PickGifts {
    public long pickGifts(int[] gifts, int k) {
        for (int i = 0; i < k; i++) {
            Arrays.sort(gifts);
            gifts[gifts.length - 1] = (int) Math.pow(gifts[gifts.length - 1], 0.5);
        }
        return Arrays.stream(gifts).sum();
    }

    public static void main(String[] args) {
        PickGifts pickGifts = new PickGifts();
        int[] gifts = {25, 64, 9, 4, 100};
        int k = 4;
        System.out.println(pickGifts.pickGifts(gifts, k));
    }
}
